<!DOCTYPE html>
<html>
    <head>
        <!-- 页面meta -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>传智健康</title>
        <meta name="description" content="传智健康">
        <meta name="keywords" content="传智健康">
        <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
        <!-- 引入样式 -->
        <link rel="stylesheet" href="../plugins/elementui/index.css">
        <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
        <link rel="stylesheet" href="../css/style.css">
        <!-- 引入组件库 -->
        <script type="text/javascript" src="../js/jquery.min.js"></script>
        <script src="../js/vue.js"></script>
        <script src="../plugins/elementui/index.js"></script>
        <script src="../js/axios-0.18.0.js"></script>


        <style>

            .el-dropdown {
                vertical-align: top;
            }
            .el-dropdown + .el-dropdown {
                margin-left: 15px;
            }
            .el-icon-arrow-down {
                font-size: 12px;
            }

            .datatable {
                position: relative;
                box-sizing: border-box;
                -webkit-box-flex: 1;
                width: 100%;
                max-width: 100%;
                font-size: 14px;
                color: rgb(96, 98, 102);
                overflow: hidden;
                flex: 1 1 0%;
            }
            .datatable td, .datatable th {
                padding: 12px 0;
                min-width: 0;
                -webkit-box-sizing: border-box;
                box-sizing: border-box;
                text-overflow: ellipsis;
                vertical-align: middle;
                position: relative;
                text-align: left;
            }
        </style>
    </head>
    <body class="hold-transition">
        <div id="app">
            <div class="content-header">
                <h1>预约管理<small>预约列表</small></h1>
                <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
                    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item>预约管理</el-breadcrumb-item>
                    <el-breadcrumb-item>预约列表</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="app-container">
                <div class="box">
                    <div class="filter-container">
                        <el-input placeholder="姓名" v-model="pagination.queryString" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                        <el-button @click="findPage()" class="dalfBut">查询</el-button>
                        <el-button @click="findAll()" class="dalfBut">查询全部</el-button>
                    </div>
                    <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                        <el-table-column type="index" align="center" label="序号"></el-table-column>
                        <el-table-column prop="name" label="预约姓名" align="center"></el-table-column>
                        <el-table-column prop="telephone" label="手机号" align="center"></el-table-column>
                        <el-table-column prop="setmealName" label="预约套餐" align="center"></el-table-column>
                        <el-table-column label="预约方式" align="center">
                            <template slot-scope="scope">
                                <span v-html="scope.row.orderType"></span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="orderDate" label="预约日期" align="center"></el-table-column>
                        <el-table-column prop="orderStatus" label="到诊情况"  align="center"></el-table-column>
                        <el-table-column label="操作" align="center">
                            <template slot-scope="scope">
                                <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">
                                    到诊状态
                                </el-button>


                                <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pagination-container">
                        <el-pagination
                            class="pagiantion"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.currentPage"
                            :page-size="pagination.pageSize"
                            layout="total, prev, pager, next, jumper"
                            :total="pagination.total">
                        </el-pagination>
                    </div>


                </div>
            </div>
        </div>
    </body>

    <script>
        var vue = new Vue({
            el: '#app',
            data:{
                activeName:'first',//添加/编辑窗口Tab标签名称
                pagination: {//分页相关属性
                    currentPage: 1,
                    pageSize:10,
                    total:100,
                    queryString:null,
                },
                dataList: [],//列表数据
                formData: {},//表单数据
                tableData:[],//新增和编辑表单中对应的检查项列表数据
                checkitemIds:[],//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
                dialogFormVisible: false,//控制添加窗口显示/隐藏
                dialogFormVisible4Edit:false//控制编辑窗口显示/隐藏
            },
            created() {
                this.findPage();
            },
            methods: {
                //查询全部
                findAll(){
                    this.pagination.queryString=null
                    this.findPage()
                },

                //编辑
                handleEdit() {


                },
                //添加
                handleAdd () {

                },
                //分页查询
                findPage() {
                    let param={
                        currentPage:this.pagination.currentPage,
                        pageSize: this.pagination.pageSize,
                        queryString: this.pagination.queryString
                    };
                    axios.post("/order/findPage",param).then(resp=>{
                        if (resp.data.flag){
                            if (resp.data.data.length==0){
                                this.pagination.total=0
                                this.dataList=[]
                            } else {
                                this.pagination.total=resp.data.data[0].total
                                this.dataList=resp.data.data
                            }

                        } else {
                            this.$message.error(resp.data.message)
                        }
                    })
                },
                // 重置表单
                resetForm() {
                    //清空表单数据
                    this.formData={}
                    //清空选择的检查项
                    this.checkitemIds=[]
                    //显示表单
                    this.dialogFormVisible=true
                    //靠前窗口
                    this.activeName='first'
                },

                // 更改是否到诊
                handleUpdate(row) {
                    //alert(row.id)
                    axios.put("/order/orderUpdateType/"+row.id).then(resp=>{
                        if (resp.data.flag){
                            this.$message({
                                type:'success',
                                message: resp.data.message
                            })
                        } else{
                            this.$message.error(resp.data.message)
                        }
                    }).catch(resp=>{
                        this.$message.error("您没有权限")
                    }).finally(resp=>{
                        this.findPage()
                    })
                },
                //切换页码
                handleCurrentChange(currentPage) {
                    this.pagination.currentPage=currentPage
                    this.findPage()
                },
                // 删除
                handleDelete(row) {
                    this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {

                        axios.delete("/order/deleteById/"+row.id).then(resp=>{

                            if (resp.data.flag){
                                //删除成功
                                this.$message({
                                    type: 'success',
                                    message: resp.data.message
                                });
                            } else {
                                //删除失败
                                this.$message.error(resp.data.message)
                            }
                        }).catch(resp=>{
                            this.$message.error("您没有权限")
                        }).finally(()=>{
                            this.findPage()
                        })


                    })
                }
            }
        })
    </script>
</html>
